package com.baizhiedu.basic.autoDesignProcessors.ApplicationContext;

import com.baizhiedu.basic.autoDesignProcessors.beanFactoryPostProcessors.MyBeanDefinitionRegistryPostProcessor;
import com.baizhiedu.basic.autoDesignProcessors.beanFactoryPostProcessors.MyBeanFactoryPostProcessor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author songyahui
 * @Date 2023/8/10 9:39
 * @Description 重写applicationContext#customizeBeanFactory:void加载自定义beanFactory
 * 以下几点需要了解
 * beanFactoryPostProcessor目标是维护BeanDefinition，beanPostProcessor目标是维护Bean；
 * addBeanFactoryPostProcessor方法由ApplicationContext提供，addBeanFactoryPostProcessor方法由BeanFactory提供
 */
public class MyApplicationContext extends ClassPathXmlApplicationContext {

    public MyApplicationContext(String... args) {
        super(args);
    }

    @Override
    public void customizeBeanFactory(DefaultListableBeanFactory beanFactory) {
        super.addBeanFactoryPostProcessor(new MyBeanFactoryPostProcessor(" by overRide customize"));
        super.addBeanFactoryPostProcessor(new MyBeanDefinitionRegistryPostProcessor(" by overRide customize"));
    }
}
